import java.io.BufferedWriter;
import java.io.IOException;
import java.util.Vector;

public class RNASpecies
{
	private String name;
	private Vector<RNASecondaryStructure> secondaryStructure;

	public RNASpecies(String name)
	{
		super();
		this.name = name;
		this.secondaryStructure = new Vector<RNASecondaryStructure>();
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public boolean addSecondaryStructure(RNASecondaryStructure arg0)
	{
		return secondaryStructure.add(arg0);
	}

	public void clear()
	{
		secondaryStructure.clear();
	}

	public RNASecondaryStructure get(int arg0)
	{
		return secondaryStructure.get(arg0);
	}

	public RNASecondaryStructure remove(int arg0)
	{
		return secondaryStructure.remove(arg0);
	}

	public int size()
	{
		return secondaryStructure.size();
	}

	public void getMinMax(int[] min_max)
	{
		for (int i = 0; i < size(); i++)
		{
			get(i).getMinMax(min_max);
		}

	}

	public void writeData(BufferedWriter bw, String family, int min, int max)
			throws IOException
	{
		for (int i = 0; i < size(); i++)
		{
			bw.write("\"" + family + "\";\"" + name + "\";"
					+ get(i).getFormatInformation(min, max) + ";");
			// System.out.println(family +";"+ name + ";" +
			// get(i).getFormatInformation() +";");
			bw.newLine();
			bw.flush();
		}
	}

	public int statTrinucleotide(int[] tabStat, int relativePosition,
			int shift, int taille, boolean useX)
	{
		String tmp;
		int count = 0;
		for (int i = 0; i < size(); i++)
		{
			tmp = get(i).getTrinucleotide(relativePosition, shift, taille, useX);
			if (!tmp.isEmpty())
			{
				tabStat[CONSTANT.index(tmp)]++;		
				count++;
			}
		}
		return count;
	}
}
